/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MovementEditorPanel.java
 *
 * Created on 11.04.2009, 20:54:23
 */
package de.tor.util;

import de.tor.obj.action.impl.LinearMovement;
import de.tor.obj.action.impl.SinusMovement;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Point2D;

/**
 *
 * @author Charon
 */
public class MovementPreviewPanel extends javax.swing.JPanel {

    /** Creates new form MovementEditorPanel */
    public MovementPreviewPanel() {
        initComponents();

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

    public void paint(Graphics g) {
        super.paint(g);
        Graphics2D g2d = (Graphics2D) g;
        SinusMovement move = new SinusMovement(getWidth() / 2, 0, 1);

        while (true) {
            move.update(1);
            Point2D.Double pos = new Point2D.Double(move.getXPos(), move.getYPos());
            System.out.println("POs " + pos);
            if (!g2d.getClipBounds().contains(pos)) {
                break;
            }

            g2d.drawOval((int) Math.rint(pos.x), (int) Math.rint(pos.y), 1, 1);

        }
        g2d.dispose();
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}
